<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>02.复习ES6继承类相关的知识</title>
</head>

<body>
    <script>
        class Person {
            constructor(name, sex, age) {
                this.name = name;
                this.sex = sex;
                this.age = age;
            }
            study() {
                console.log('学习')
            }
        }
        //在写继承的关系的时候，一定是先写子类，然后根据不同的子类中相同的功能向上抽取父类
        class Student extends Person {
            //如果子类没有明显的写出构造器，一旦继承了父类，则使用的父类中的构造器
            //如果子类已经明显的定义出来的构造器,所以需要在自身的构造器里面调用父类的构造器
            address = '北京市'
            constructor(name, sex, age, height) {
                super(name, sex, age);
                this.height = height;
            }
        }
        let s1 = new Student('张三', '男', 23, 170);
        console.log(s1)

        let s2 = new Student('李四', '男', 24, 180);
        console.log(s2)

        s1.study();

    </script>
</body>

</html>